Skip to content

Conversation

@JOJ0
Copy link
Member

@JOJ0 JOJ0 commented Aug 31, 2025

Often last.fm does not find artist genres for delimiter-separated artist names (eg. "Artist One, Artist Two") or where multiple artists are combined with "concatenation words" like "and" , "+", "featuring" and so on.

This fix gathers each artist's last.fm genre separately by using Beets' mutli-valued albumartists field to improve the likeliness of finding genres in the artist genre fetching stage.

Additionally refactoring was done along the existing genre fetching helper functions (fetch_album_genre, fetch_track_genre, ...):

  • last.fm can be asked for genre for these combinations of metadata:

    • albumartist/album
    • artist/track
    • artist
  • Instead of passing Album or Item objects directly to these helpers., generalize them and pass the (string) metadata directly.

  • Passing "what's to fetch" in the callers instead of hiding it in the methods also helps readability in _get_genre()

  • And reduces the requirement at hand for another additional method (or adaptation) to support "multi-albumartist genre fetching"

  • Documentation

  • Changelog

  • Tests

@github-actions
Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from 86e07aa to 2a27349 Compare August 31, 2025 19:52
@codecov
Copy link

codecov bot commented Aug 31, 2025

Codecov Report

❌ Patch coverage is 22.50000% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.38%. Comparing base (55667fa) to head (314a914).
⚠️ Report is 28 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/lastgenre/__init__.py 22.50% 29 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5981      +/-   ##
==========================================
- Coverage   66.50%   66.38%   -0.13%     
==========================================
  Files         117      117              
  Lines       18123    18141      +18     
  Branches     3071     3081      +10     
==========================================
- Hits        12052    12042      -10     
- Misses       5415     5444      +29     
+ Partials      656      655       -1     
Files with missing lines Coverage Δ
beetsplug/lastgenre/__init__.py 53.39% <22.50%> (-4.85%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JOJ0 JOJ0 changed the title lastgenre: Fix multi-artist-albums lastgenre: Fix fetching albumartist genre for multi-artist albums Aug 31, 2025
@JOJ0 JOJ0 changed the title lastgenre: Fix fetching albumartist genre for multi-artist albums lastgenre: Fix fetching artist genre for multi-artist albums Aug 31, 2025
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch 3 times, most recently from c7fec68 to 58463f0 Compare September 9, 2025 05:35
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from 58463f0 to 314a914 Compare September 11, 2025 06:00
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from 314a914 to 283817d Compare November 16, 2025 07:46
@beetbox beetbox deleted a comment from sourcery-ai bot Nov 16, 2025
JOJ0 pushed a commit that referenced this pull request Nov 16, 2025
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch 2 times, most recently from b315397 to bea2594 Compare November 19, 2025 06:24
j0j0 added 3 commits November 19, 2025 07:45
Reduce fetcher methods to 3: last.fm can be asked for
for a genre for these combinations of metadata:

- albumartist/album
- artist/track
- artist

Passing them in the callers instead of hiding it in the
methods also helps readability in _get_genre().
In case the albumartist genre can't be found (often due to variations of
artist-combination wording issues, eg "featuring", "+", "&" and so on)
use the albumartists list field, fetch a genre for each artist
separately and concatenate them.
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from bea2594 to 7668957 Compare November 19, 2025 06:47
@JOJ0 JOJ0 changed the title lastgenre: Fix fetching artist genre for multi-artist albums lastgenre: Use albumartists field to improve last.fm results / fetch_genre helpers refactor Nov 19, 2025
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from 7668957 to c496627 Compare November 19, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants